﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuotePoll;

namespace TestQuote
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                if (args.Length < 2)
                    throw new Exception("Usage: TestQuote.exe ServerFile symbol");

                bool blUpdate;
                var qc = new QuoteClass(args[1], args[0]);

                do
                {
                    blUpdate = qc.UpdateQuotes();
                }
                while (blUpdate == false);

                var ask = qc.Ask;
                double bid = qc.Bid;

                Console.WriteLine("Ask: " + ask);
                Console.WriteLine("Bid: " + bid);
                Console.WriteLine("ServerDate: " + qc.ServerDateTime);

                while (true)
                {
                    qc.UpdateQuotes();

                    if (Math.Abs(qc.Ask - ask) > double.Epsilon || Math.Abs(qc.Bid - bid) > double.Epsilon)
                    {

                        ask = qc.Ask;
                        bid = qc.Bid;
                        Console.WriteLine("Ask: " + ask);
                        Console.WriteLine("Bid: " + bid);
                        Console.WriteLine("ServerDate: " + qc.ServerDateTime);
                       
                    }

                }  

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}
